<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" type="image/x-icon"
	href="${ctxPath}/static/images/lukk.ico" media="screen" />
<link rel="icon" href="${ctxPath}/static/images/lukk.ico"
	type="image/x-icon" />
<link rel="bookmark" href="${ctxPath}/static/images/lukk.ico"
	type="image/x-icon" />
<title>管理页面</title>
</head>
<body class="sticky-header"
	onload="indexmenu('${oneMenu}','${twoMenu}');">
	<%@ include file="../index/index.jsp"%>
	<section>
		<div class="main-content" style="overflow-y: auto">
			<!-- 地址栏-->
			<div class="page-heading">
				<h3>鹿客帮</h3>
				<ul class="breadcrumb">
					<li><a>录入意向信息</a></li>
					<li class="active">添加意向师傅</li>
				</ul>
			</div>
			<!--这里是写一些内容的  -->
			<h4>&nbsp;&nbsp;&nbsp;添加信息:</h4>
			<form id="addPotentialWorkerForm" class="form-horizontal"
				method="post">
				<input type="hidden" name="id" value="0">
				<div class="form-group">
					<label class="col-md-2 col-sm-2 control-label">师傅姓名:</label>
					<div class="col-md-4">
						<input type="text" placeholder="师傅姓名" class="form-control"
							name="workerName">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 col-sm-2 control-label">师傅手机:</label>
					<div class="col-md-4">
						<input type="text" placeholder="师傅手机" class="form-control"
							id="workerPhoneNumber" name="phoneNumber">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 col-sm-2 control-label">意向等级:</label>
					<div class="col-md-4">
						<select class="form-control" name="potentialLevelID"
							id="potentialLevelSelect">
						</select>
					</div>
				</div>
			</form>
			<br /> <br /> <br /> <br />
			<button class="btn btn-info finish"
				style="position: relative; margin-left: 300px;"
				onclick="addPotentialWroker()">添加</button>
			<button class="btn btn-info finish"
				style="position: relative; margin-left: 200px;"
				onclick="javascript:$('#addPotentialWorkerForm')[0].reset()">重置</button>
		</div>
	</section>
</body>
<script type="text/javascript">
	//添加意向工人信息
	function addPotentialWroker() {
		var phone = $("#workerPhoneNumber").val();
		if (phone && /^1[3|4|5|7|8]\d{9}$/.test(phone)) {
			$.post("${ctxPath}/potentialWorker/add", $(
					"#addPotentialWorkerForm").serialize(), function(data) {
				if (data) {
					toastr.success('保存成功，请去我的录入中查看！');
					$('#addPotentialWorkerForm')[0].reset();
				} else {
					toastr.info("该手机号无法添加，因手机号已被添加过了，请继续努力！");
					$('#addPotentialWorkerForm')[0].reset();
				}
			});
		} else {
			toastr.error("手机号码不可使用");
		}
	}
	$(document).ready(
			function() {
				//后台获取师傅意向程度下拉项
				$.post('${ctxPath}/potentialLevel/select', function(data) {
					$(data).each(
							function(index, currData) {
								$("#potentialLevelSelect").append(
										"<option value="+currData.id+">"
												+ currData.levelCode + "--("
												+ currData.levelContent
												+ ")</option>");
							});
				});
			});
</script>
<script src="${ctxPath}/static/js/jquery.nicescroll.js"></script>
</html>
